package com.tizona.entity;

import java.util.Date;

/**
 * Created by Vitaliy Kim.
 * Date: 11.09.2005
 * Time: 15:03:06
 */
public class SeProp extends Prop implements com.tizona.entity.tarification.Parameter {

    /** persistent field */
    private String value;

    /** persistent field */
    private Date date;

    /** nullable persistent field */
    private Se se;

    /**
     * Field for track by date_field
     */
    private boolean changed = false;

    private boolean create = false;


    public SeProp(String value) {
        this.value = value;
    }

    public SeProp(Date date) {
        this.date = date;
    }

    /**
     * Create new param
     * @param create
     * @param date
     */
    public SeProp(Date date , boolean create) {
        this.create = create;
        this.date = date;
        changed = true;
    }

    public SeProp(String value, boolean create) {
        this.value = value;
        this.create = create;
        changed = true;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        changed = true;
        this.value = value;
    }

    public Se getSe() {
        return se;
    }

    public void setSe(Se se) {
        this.se = se;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        changed = true;
        this.date = date;
    }

    public boolean isChanged() {
        return changed;
    }

    public void setChanged(boolean changed) {
        this.changed = changed;
    }

    public boolean isCreate() {
        return create;
    }

    public void setCreate(boolean create) {
        this.create = create;
    }

    public String asString()
    {
        return value;
    }

    public int asInteger()
    {
        try
        {
            return Integer.parseInt(value);
        }
        catch(Exception exception)
        {
            log.error("LC: " + se.getSeId() + " message: " +exception.getMessage());
            return 0;
        }
    }

    public float asFloat()
    {
        try
        {
            return Float.parseFloat(value);
        }
        catch(Exception exception)
        {
            log.error("LC: " + se.getSeId() + " message: " +exception.getMessage());
            return 0.0F;
        }
    }

}
